﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>数据字典明细管理</title>
<#include "../common/link.ftl">
    <script type="text/javascript">
        $(function () {
            $(".btn-input").on("click", function () {
                var pid = '${qo.parentId}';
                if(!pid || pid == -1){
                    $.messager.alert("温馨提示", "请先选中字典目录")
                    return ;
                }
                $("#editForm")[0].reset();
                var json = $(this).data("json");
                var parentName = $("#dicDirUl li.active").find("a").html();
                $("#editForm input[name='parentName']").val(parentName);
                if (json) {
                    $("input[name=id]").val(json.id);
                    $("input[name=title]").val(json.title);
                    $("input[name=sequence]").val(json.sequence);


                }
                $("#myModal").modal("show");
            })
            $(".btn-delete").on("click", function () {
                var id = $(this).data("id");
                $.messager.confirm("温馨提示", "确认是否删除?", function () {
                    $.post("/systemdictionaryitem/delete.do", {id: id}, function (data) {
                        if (data.success) {
                            $.messager.alert("温馨提示", "两秒后自动刷新");
                            window.setTimeout(function () {
                                window.location.reload();
                            }, 2000)
                        } else {
                            alert(data.msg);
                        }
                    })
                })
            })
            $(".btn-primary").on("click", function () {
                $("#editForm").ajaxSubmit(function (data) {
                    if (data.success) {
                        $.messager.alert("温馨提示", "两秒后自动刷新");
                        window.setTimeout(function () {
                            window.location.reload();
                        }, 2000)
                    } else {
                        alert(data.msg);
                    }
                })
            })
            $(".dicDir").on("click", function () {
                var parentid = $(this).data("pid");
                $("#parentId").val(parentid);
                $("#searchForm").submit();
            })
        })
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<#include "../common/navbar.ftl">
    <!--菜单回显-->
<#assign currentMenu="systemdictionaryitem"/>
<#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>数据字典明细管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/systemdictionaryitem/list.do" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <input type="hidden" name="parentId" id="parentId" value="${(qo.parentId)!}">
                <@shiro.hasPermission name="systemdictionaryitem:input">
                    <a class="btn btn-success btn-input" style="margin: 10px">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                </@shiro.hasPermission>
                    <div class="row">

                        <div class="  col-sm-3">
                            <div class="panel panel-info">
                                <div class="panel-heading"><strong>字典明细</strong></div>
                                <ul class="list-group" id="dicDirUl">
                                <#list dics as d>
                                    <li class="list-group-item"><a class="dicDir" data-pid="${d.id}">${d.title}</a></li>
                                </#list>
                                    <script>
                                        $(".dicDir[data-pid='${qo.parentId}']").closest("li").addClass("active");
                                        $(".dicDir[data-pid='${qo.parentId}']").css("color", "white")
                                    </script>
                                </ul>
                            </div>
                        </div>
                        <div class="col-sm-9">
                            <!--编写内容-->
                            <div class="box-body table-responsive no-padding ">
                                <table class="table table-hover table-bordered">
                                    <tr>
                                        <th>编号</th>
                                        <th>标题</th>
                                        <th>序号</th>
                                        <th>操作</th>
                                    </tr>
                                <#list result.list as entity>
                                    <tr>
                                        <td>${entity_index+1}</td>
                                        <td>${entity.title}</td>
                                        <td>${entity.sequence}</td>
                                        <td>
                                            <@shiro.hasPermission name="systemdictionaryitem:input">
                                                <a data-json='${entity.json}' class="btn btn-info btn-xs btn-input">
                                                    <span class="glyphicon glyphicon-pencil"></span> 编辑
                                                </a>
                                            </@shiro.hasPermission>
                                            <a data-id='${entity.id}' class="btn btn-danger btn-xs btn-delete">
                                                <span class="glyphicon glyphicon-trash"></span> 删除
                                            </a>
                                        </td>
                                    </tr>
                                </#list>
                                </table>
                                <!--分页-->
                            <#include "../common/page.ftl">
                            </div>
                        </div>
        </section>
    </div>
<#include "../common/footer.ftl">
</div>
</div >
</div >
</form>


<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">数据字典明细编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/systemdictionaryitem/saveOrUpdate.do" method="post"
                      id="editForm">
                    <input type="hidden" name="id">
                    <input type="hidden" name="parentId" value="${(qo.parentId)!}">
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="name" class="col-sm-3 control-label">字典目录：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="parentName" name="parentName" readonly
                            >
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-3 control-label">明细标题：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="title" name="title"
                                   placeholder="请输入数据字典明细标题">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-3 control-label">明细序号：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="sequence" name="sequence"
                                   placeholder="请输入数据字典明细序号">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary">提交</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>
